package bark.sihu;

import org.hq.tool.GetSpringBean;
import org.hq.util.OkHttps;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.io.IOException;

public class UpH implements Runnable {
    private OkHttps http = GetSpringBean.getBean(OkHttps.class);
    private String url;
    public UpH(String url) {
        this.url = url;
    }
    @Override
    public void run() {
        try {
          String html=  http.getRequestToStringSync(url);
            Document doc = Jsoup.parse(html);
            //读取下一页的标签位置
            Element pc_pagination = doc.getElementsByClass("pc_pagination").first();
            //获取最后一页链接数量
            String href = pc_pagination.getElementsByTag("a").last().attr("href");//获取 a 标签 属性
            // System.out.println(href);
            //切割视频地址
            int count = Integer.parseInt(href.substring(href.indexOf("index_") + 6, href.indexOf(".html")));
            System.out.println(count);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
